<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  label-width="68px">
      <el-form-item label="保卫项目" prop="securityProject">
        <el-input
          v-model="queryParams.securityProject"
          placeholder="请输入保卫项目"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="具体问题隐患" prop="hiddenDangers"  label-width="98px">
        <el-input
          v-model="queryParams.hiddenDangers"
          placeholder="请输入具体问题隐患"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="稳控化解措施" prop="resolutionMeasures" label-width="98px">
        <el-input
          v-model="queryParams.resolutionMeasures"
          placeholder="请输入稳控化解措施"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="责任人" prop="presonLiable" label-width="58px">
        <el-input
          v-model="queryParams.presonLiable"
          placeholder="请输入责任人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="监管JS代表室" prop="representativeOffice" v-show="showSearch">
        &lt;!&ndash;<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />&ndash;&gt;
        <el-select
          v-model="queryParams.deptId"
          :options="deptOptions"
          placeholder="监管JS代表室"
          clearable
        >
          <el-option
            v-for="dict in dict.type.yh_representative_office"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>-->
     <!-- <el-form-item label="化解时限" prop="timeLimit" v-show="showSearch">
        <el-input
          v-model="queryParams.timeLimit"
          placeholder="请输入化解时限"
          clearable
          @keyup.enter.native="handleQuery"
        />-->
     <!-- </el-form-item>-->
      <br/>
      <div style="text-align:right; " >

          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

      </div>
      <br/>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['lys:security:add']"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--        type="success"-->
<!--        plain-->
<!--        icon="el-icon-edit"-->
<!--        size="mini"-->
<!--        :disabled="single"-->
<!--        @click="handleUpdate"-->
<!--        v-hasPermi="['lys:security:query','lys:security:edit']"-->
<!--      >修改</el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['lys:security:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['lys:security:import']"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['lys:security:export']"
        >导出</el-button>
      </el-col>
<!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" ></right-toolbar>-->
    </el-row>

    <el-table v-loading="loading" :data="securityworkList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column type="index" label="序号"   :index="indexMethod" align="center"/>
      <el-table-column label="保卫类别" align="center"  prop="securityType" >
      <template slot-scope="scope">
        <dict-tag :options="dict.type.yh_security_grade" :value="scope.row.securityType"/>
      </template>
      </el-table-column>
      <el-table-column label="保卫项目" align="center"width="150"  prop="securityProject" />
      <el-table-column label="具体问题隐患" align="center"  prop="hiddenDangers" />
      <el-table-column label="稳控化解措施" align="center"  prop="resolutionMeasures" />
      <el-table-column label="责任人" align="center" prop="presonLiable" width="100" />
     <!-- <el-table-column label="军事代表室" align="center" prop="representativeOffice" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_representative_office" :value="scope.row.representativeOffice"/>
        </template>
      </el-table-column>-->

      <el-table-column label="军代表室" align="center" prop="representativeOffice" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_representative_office" :value="scope.row.representativeOffice"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon=""
            @click="handleUpdate(scope.row)"
            v-hasPermi="['lys:security:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon=""
            @click="handleDelete(scope.row)"
            v-hasPermi="['lys:security:remove']"
          >删除</el-button>
          <el-button
          size="mini"
          type="text"
          icon=""
          @click="handleView(scope.row)"
          v-hasPermi="['lys:security:query']"
        >详细</el-button>
<!--          <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['lys:security:remove', 'lys:security:query']">-->
<!--                <span class="el-dropdown-link">-->
<!--                  <i class="el-icon-d-arrow-right el-icon&#45;&#45;right"></i>更多-->
<!--                </span>-->
<!--            <el-dropdown-menu slot="dropdown">-->
<!--              <el-dropdown-item command="handleView"-->
<!--                                v-hasPermi="['lys:security:query']">详情</el-dropdown-item>-->
<!--              <el-dropdown-item command="handleDelete"-->
<!--                                v-hasPermi="['lys:security:remove']">删除</el-dropdown-item>-->
<!--            </el-dropdown-menu>-->
<!--          </el-dropdown>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    </el-card>
    <!-- 添加或修改保卫工作对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">基本信息
              </p>
            </el-divider>
          </el-header>

          <el-main>

            <el-row>

              <el-col :span="12">
                <el-form-item label="保卫类别" prop="securityType"  >
                  <!--<el-input v-model="form.securityType" placeholder="请输入保卫类别" />-->
                  <el-select
                    v-model="form.securityType"
                    placeholder="保卫类别"
                    clearable
                    style="width: 330px"
                  >
                    <el-option
                      v-for="dict in dict.type.yh_security_grade"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="保卫项目" prop="securityProject">
                  <el-input v-model="form.securityProject" placeholder="请输入保卫项目" clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="责任人" prop="presonLiable">
                  <el-input v-model="form.presonLiable" placeholder="请输入责任人" clearable />
                </el-form-item>

              </el-col>
              <el-col :span="12">
                <el-form-item label="军事代表室" prop="representativeOffice">
                  <el-select
                    v-model="form.representativeOffice"
                    placeholder="请选择军事代表室"
                    clearable
                    style="width: 330px"
                  >
                    <el-option
                      v-for="dict in dict.type.yh_representative_office"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"/>
                  </el-select>
<!--                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />-->
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
</el-container>



            <el-container>
            <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">化解信息
              </p>
            </el-divider>
            </el-header>
<el-main>
            <el-row>
              <el-col :span="24">
                  <el-form-item label="化解时限" prop="timeLimit" >
                    <el-date-picker clearable
                                    v-model="form.timeLimit"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="请选择化解时限"
                                    style="float: left;width: 500px">
                    </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
                  <el-row>
              <el-col :span="24">
                <el-form-item label="具体问题隐患" prop="hiddenDangers">
                  <el-input v-model="form.hiddenDangers" type="textarea" :rows="4" placeholder="请输入具体问题隐患" clearable/>
                </el-form-item>
              </el-col>
                  </el-row>
<el-row>
              <el-col :span="24">
                <el-form-item label="稳控化解措施" prop="resolutionMeasures">

                  <el-input v-model="form.resolutionMeasures" type="textarea" :rows="4" placeholder="请输入稳控化解措施" clearable/>
                </el-form-item>
              </el-col>
            </el-row>
<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="责任人" prop="presonLiable">-->
<!--                  <el-input v-model="form.presonLiable" placeholder="请输入责任人" />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
             <!-- <el-col :span="12">
                <el-form-item label="监管JS代表室" prop="representativeOffice">
                  <treeselect v-model="form.deptId"  :option="deptOptions" :show-count="true" placeholder="请选择归属部门" />
                 &lt;!&ndash; <el-input v-model="form.representativeOffice" placeholder="请输入JS代表室" />&ndash;&gt;
                 &lt;!&ndash; <el-select
                    v-model="form.representativeOffice"
                    placeholder="监管JS代表室"

                    style="width: 330px"
                  >
                    <el-option
                      v-for="dict in dict.type.yh_representative_office"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>&ndash;&gt;
                </el-form-item>
              </el-col>-->

<!--              <el-col :span="12">-->
<!--                <el-form-item label="监管JS代表室" prop="deptId">-->

<!--                  <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />-->


                  <!-- <el-select v-model="form.representativeOffice" placeholder="请选择监管JS代表室" style="width: 100%">
                     <el-option
                       v-for="dict in dict.type.yh_representative_office"
                       :key="dict.value"
                       :label="dict.label"
                       :value="dict.value"
                     ></el-option>
                   </el-select>-->
                  <!--<el-input v-model="form.representativeOffice" placeholder="请输入监管JS代表室" style="width: 95%"/>-->
<!--                </el-form-item>-->
<!--              </el-col>-->


              <el-col :span="24">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
              </el-col>
</el-main>
            </el-container>

          <!-- <el-form-item label="备注" prop="remark">
             <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注1" prop="note1">
             <el-input v-model="form.note1" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注2" prop="note2">
             <el-input v-model="form.note2" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注3" prop="note3">
             <el-input v-model="form.note3" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注4" prop="note4">
             <el-input v-model="form.note4" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注5" prop="note5">
             <el-input v-model="form.note5" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注6" prop="note6">
             <el-input v-model="form.note6" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注7" prop="note7">
             <el-input v-model="form.note7" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注8" prop="note8">
             <el-input v-model="form.note8" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注9" prop="note9">
             <el-input v-model="form.note9" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注10" prop="note10">
             <el-input v-model="form.note10" type="textarea" placeholder="请输入内容" />
           </el-form-item>-->

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查看保卫工作信息对话框 -->
    <el-dialog :title="view.title" :visible.sync="view.open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">保卫工作详细信息
              </p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-col :span="12">
                <el-form-item label="保卫类别" prop="securityType"  >
                  <!--<el-input v-model="form.securityType" placeholder="请输入保卫类别" />-->
                  <el-select
                    v-model="form.securityType"
                    placeholder="保卫类别"
                    clearable
                    style="width: 330px"
                    disabled="true"
                  >
                    <el-option
                      v-for="dict in dict.type.yh_security_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"/>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="保卫项目" prop="securityProject">
                  <el-input v-model="form.securityProject" placeholder="请输入保卫项目" :readonly="true" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="具体问题隐患" prop="hiddenDangers">
                  <el-input v-model="form.hiddenDangers" placeholder="请输入具体问题隐患" :readonly="true" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="稳控化解措施" prop="resolutionMeasures">
                  <el-input v-model="form.resolutionMeasures" placeholder="请输入稳控化解措施"  :readonly="true"/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="责任人" prop="presonLiable">
                  <el-input v-model="form.presonLiable" placeholder="请输入责任人" :readonly="true"/>
                </el-form-item>
              </el-col>
              <!-- <el-col :span="12">
                 <el-form-item label="监管JS代表室" prop="representativeOffice">
                   <treeselect v-model="form.deptId"  :option="deptOptions" :show-count="true" placeholder="请选择归属部门" />
                  &lt;!&ndash; <el-input v-model="form.representativeOffice" placeholder="请输入JS代表室" />&ndash;&gt;
                  &lt;!&ndash; <el-select
                     v-model="form.representativeOffice"
                     placeholder="监管JS代表室"

                     style="width: 330px"
                   >
                     <el-option
                       v-for="dict in dict.type.yh_representative_office"
                       :key="dict.value"
                       :label="dict.label"
                       :value="dict.value"
                     />
                   </el-select>&ndash;&gt;
                 </el-form-item>
               </el-col>-->




            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="化解时限" prop="timeLimit">
                  <el-date-picker
                                  v-model="form.timeLimit"
                                  type="date"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择化解时限">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" type="textarea" :readonly="true" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-main>
          <!-- <el-form-item label="备注" prop="remark">
             <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注1" prop="note1">
             <el-input v-model="form.note1" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注2" prop="note2">
             <el-input v-model="form.note2" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注3" prop="note3">
             <el-input v-model="form.note3" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注4" prop="note4">
             <el-input v-model="form.note4" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注5" prop="note5">
             <el-input v-model="form.note5" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注6" prop="note6">
             <el-input v-model="form.note6" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注7" prop="note7">
             <el-input v-model="form.note7" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注8" prop="note8">
             <el-input v-model="form.note8" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注9" prop="note9">
             <el-input v-model="form.note9" type="textarea" placeholder="请输入内容" />
           </el-form-item>
           <el-form-item label="备注10" prop="note10">
             <el-input v-model="form.note10" type="textarea" placeholder="请输入内容" />
           </el-form-item>-->
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
      <el-button @click="viewCancel">返回</el-button>
      </div>
     <!-- <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>-->
    </el-dialog>
   <!-- <el-dialog :title="view.title" :visible.sync="view.open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <el-container>

          <el-header>
            <el-header>
              <el-divider content-position="left">
                <p style="color: #00afff; font-size: 20px;">保卫工作基本信息</p>
              </el-divider>
            </el-header>
          </el-header>


          <el-main>
            <el-descriptions  direction="vertical" :column="2" border>


              <el-descriptions-item  label="保卫类别">{{ form.securityType}}</el-descriptions-item>
              <dict-tag :options="dict.type.yh_security_type" :value="form.securityType"/>
              <el-descriptions-item  label="保卫项目">{{ form.securityProject}}</el-descriptions-item>

            </el-descriptions>

            <el-descriptions  direction="vertical" :column="3" border>
              <el-descriptions-item label="具体问题隐患">{{ form.hiddenDangers}}</el-descriptions-item>
              <el-descriptions-item label="稳控化解措施">{{ form.resolutionMeasures}}</el-descriptions-item>
              <el-descriptions-item label="监管Js代表室">{{ form.deptId}}</el-descriptions-item>
              <dict-tag :options="dict.type.yh_representative_office" :value="form.representativeOffice"/>
            </el-descriptions>
            <el-descriptions  direction="vertical" :column="3" border>
              <el-descriptions-item  label="化解时限">{{ form.timeLimit}}</el-descriptions-item>
              <el-descriptions-item  label="责任人">{{ form.presonLiable}}</el-descriptions-item>
              <el-descriptions-item  label="备注">{{ form.remark}}</el-descriptions-item>
            </el-descriptions>
          </el-main>
        </el-container>
      </el-form>
    </el-dialog>-->
    <!-- &lt;!&ndash; 用户导入对话框 &ndash;&gt;-->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
         <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;color: red;" @click="importTemplate" >下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<style>
  .el-header, .el-footer {
    background-color: #FFFFFF;
    color: #333;
    text-align: left;
    line-height: 60px;
    font-style: oblique;

  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #FFFFFF;
    color: #333;
    text-align: center;
    line-height: 160px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }

  /*对话框标题样式*/
  .el-dialog__title{
    /*color: #1ab394;*/
    font-weight: bold;
    font-size: 25px;
  }
</style>
<script>
  import { listSecuritywork, getSecuritywork, delSecuritywork, addSecuritywork, updateSecuritywork } from "@/api/module/lys/security/security";
  import { getToken } from "@/utils/auth";

  import watermark from "watermark-dom";

  export default {
    name: "Securitywork",
    dicts:['yh_representative_office','yh_security_grade','yh_deptid'],

    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: false,
        // 总条数
        total: 0,

        // 保卫工作表格数据
        securityworkList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          securityType: null,
          securityProject: null,
          representativeOffice:null,
          hiddenDangers: null,
          resolutionMeasures: null,
          presonLiable: null,
          timeLimit: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null,
          orderByColumn:"createTime",
          isAsc:"desc"
        },
        // 表单参数
        form: {},
        // 用户查询参数
        view:{
          // 是否显示弹出层（用户查询）
          open: false,
          // 弹出层标题（用户查询）
          title: "保卫工作详细信息",
        },
        // 用户导入参数
        upload: {
          // 是否显示弹出层（用户导入）
          open: false,
          // 弹出层标题（用户导入）
          title: "",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部project
          headers: { Authorization: "Bearer " + getToken() },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/lys/security/importData"
        },

        // 表单校验
        rules: {
          securityProject: [
            { required: true, message: "保卫项目不能为空", trigger: "blur" },
          ],
         securityType: [
              { required: true, message: "保卫类型不能为空", trigger: "blur" },
            ],
          hiddenDangers: [
            { required: true, message: "具体问题隐患不能为空", trigger: "blur" },
          ],
          timeLimit: [
            { required: true, message: "化解时限不能为空", trigger: "blur" },
          ],
          presonLiable: [
            { required: true, message: "责任人不能为空", trigger: "blur" },
          ],
          representativeOffice:[
            { required: true, message: "军事代表室不能为空", trigger: "blur" },
          ],
         /*  representativeOffice: [
               { required: true, message: "监管JS代表室不能为空", trigger: "blur" },
             ],*/
        }
      };
    },
    mounted() {
      // 加载水印
      const username = this.$store.state.user.nickname;
      watermark.load({ watermark_txt: ' ' });
    },

    created() {
      this.getList();

    },
    methods: {
      indexMethod(index) {
        index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
        return index
      },  /** 下载模板操作 */
      importTemplate() {
        this.download('/lys/security/importTemplate', {
        }, `user_template_${new Date().getTime()}.xlsx`)
      },

      // 取消按钮
      viewCancel() {
        this.view.open = false;
      },

      // 文件上传中处理
      handleFileUploadProgress(event, file, fileList) {
        this.upload.isUploading = true;
      },
      // 文件上传成功处理
      handleFileSuccess(response, file, fileList) {
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
        this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        this.$refs.upload.submit();
      },

      /** 查询保卫工作列表 */
      getList() {
        this.loading = true;
        listSecuritywork(this.queryParams).then(response => {
          this.securityworkList = response.rows;

          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          securityType: null,
          securityProject: null,
          hiddenDangers: null,
          resolutionMeasures: null,
          presonLiable: null,
          timeLimit: null,
          representativeOffice: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          remark: null,
          note1: null,
          note2: null,
          note3: null,
          note4: null,
          note5: null,
          note6: null,
          note7: null,
          note8: null,
          note9: null,
          note10: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.is = selection.map(item => item.securityProject)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      // 更多操作触发
      handleCommand(command, row) {
        switch (command) {
          case "handleView":
            this.handleView(row);
            break;
          case "handleDelete":
            this.handleDelete(row);
            break;
          default:
            break;
        }
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();

        this.open = true;
        this.title = "保卫工作";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();

        const id = row.id || this.ids
        getSecuritywork(id).then(response => {
          this.form = response.data;
          this.open = true;
          this.title = "修改保卫工作";
        });
      },
      /** 详细按钮操作 */
      handleView(row) {
        const id = row.id || this.ids
        getSecuritywork(id).then(response => {
          this.form = response.data;
          this.$router.push({ path:"/dangzheng/lyssecuritydetail", query: {id}});
         // this.view.open = true;
          /*this.view.title = "查看保卫工作信息";*/
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              this.form.hiddenDangers=this.form.hiddenDangers.slice(3,-4)
              updateSecuritywork(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              this.form.hiddenDangers=this.form.hiddenDangers.slice(3,-4)
              addSecuritywork(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        const i=row.securityProject||this.is;

        this.$modal.confirm('是否确认删除保卫项目为"' + i + '"的项目？').then(function() {
          return delSecuritywork(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导入按钮操作 */
      handleImport() {
        this.upload.title = "保卫工作导入";
        this.upload.open = true;
      },

      /** 导出按钮操作 */
      handleExport() {
        this.download('lys/security/export', {
          ...this.queryParams
        }, `security_${new Date().getTime()}.xlsx`)
      }
    }
  };

</script>
